﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using Kernel;

namespace SppdProjectHelper
{
    public partial class pad_file : UserControlEx,IControlEx
    {
        public pad_file()
        {
            InitializeComponent();
        }

        /*控件只有此种实例化方式*/
        public pad_file(IControlPad pad)
        {
            InitializeComponent();

            /*传入参数*/
            _pad = pad;
            this.Dock = DockStyle.Fill;

            this.tableLayoutPanel_main.Controls.Add(_pfv, 0, 0);

            this.AddExControl(this._pfv);
        }

        public Project Project { get; set; }

        /*私有变量*/
        private IControlPad _pad = null;

        private PrjFileViewer _pfv = new PrjFileViewer();

        private void UI_Init()
        {
            this.AddExControl(this.toolStrip_main);

            this.InitAllExControls();
        }

        private void UI_Load()
        {
            this._pfv.Project = Project;

            this.LoadAllExControls();
        }

        private void UI_Update()
        {
            this.UpdateAllExControls();
        }

        private void ToolStripButton_Click(object sender, EventArgs e)
        {
            ToolStripButton tsb = (ToolStripButton)sender;
            switch (tsb.Text)
            {
                case "返回":
                    {
                        _pad.Back();
                    }
                    break;
            }
        }

        #region
        void IControlEx.Init() { UI_Init(); }
        void IControlEx.Load() { UI_Load(); }
        void IControlEx.Update() { UI_Update(); }
        void IControlEx.Save() { }
        bool IControlEx.Updated
        {
            get { return false; }
        }
        #endregion
    }
}
